<template>
  <!-- 设置界面 -->
  <div>
    <van-nav-bar title="设置" left-arrow @click-left="onClickLeft" />
    <h5>账号管理</h5>
    <van-cell title="个人资料" is-link @click="to_personal" />
    <van-cell title="收货地址" is-link @click="to_address" />
    <h5>关于</h5>
    <van-cell title="关于商城" is-link @click="tishi" />
    <van-cell title="意见反馈" is-link @click="tishi" />
    <van-cell title="协议规则" is-link @click="tishi" />
    <van-cell title="资质证照" is-link @click="tishi" />
    <van-cell title="小米商城用户协议" is-link @click="tishi" />
    <van-cell title="小米账号用户协议" is-link @click="tishi" />
    <van-cell title="小米账号隐私协议" is-link @click="tishi" />
    <br><br>
    <!-- 退出登录 -->
    <van-row v-if="sta==1">
      <van-col :span="22" :offset="1">
        <van-button round block @click="showPopup">退出登录</van-button>
        <van-popup v-model="show" position="bottom" :style="{ height: '20%'}">
          <p class="one">退出账号</p>
          <p class="two">确定要退出该账号吗?</p>
          <van-row>
            <van-col :span="8" :offset="3">
              <van-button round block @click="showDouwn">取消</van-button>
            </van-col>
            <van-col :span="8" :offset="1">
              <van-button round block plain @click="exit" style="" color="red">确定</van-button>
            </van-col>
          </van-row>
        </van-popup>
      </van-col>
    </van-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      show: false,
      sta: 0,
    };
  },
  methods: {
    // 返回上一页
    onClickLeft() {
      this.$router.go(-1);
    },
    //关闭弹窗
    showDouwn() {
      this.show = false;
    },
    //打开弹窗
    showPopup() {
      this.show = true;
    },
    // 退出登录
    exit() {
      localStorage.setItem("sta", "{}");
      this.$router.go(-1);
    },
    //尚未完善功能提示
    tishi() {
      this.$toast("该功能尚未完善，敬请期待");
    },
    // 前往个性信息界面时判断登录状态
    to_personal() {
      if (this.sta == 1) {
        this.$router.push("/personal");
      } else {
        this.$toast("请先登录");
      }
    },
    to_address() {
      if (this.sta == 1) {
        this.$router.push("/address");
      } else {
        this.$toast("请先登录");
      }
    },
  },
  created() {
    let sta = localStorage.getItem("sta");
    sta = JSON.parse(sta);
    if (sta.sx != undefined) {
      this.sta = sta.sx;
    }
  },
};
</script>

<style scoped>
h5 {
  padding-left: 4.3%;
  margin-bottom: 2%;
}
.one {
  text-align: center;
}
.two {
  text-align: center;
  font-size: 10px;
  color: rgba(0, 0, 0, 0.3);
}
</style>